package com.glodon.paas.document.api.bean;

import java.util.Date;
import java.util.List;

import com.glodon.paas.storage.InitResult;
import com.glodon.paas.storage.Part;

/**
 * represent a version of a document
 * 
 * @author guojf
 */
public class Revision {

    private String     id;
    // revision number
    private int        revisionNumber;
    // upload time
    private Date       timestamp;
    // file size
    private long       fileSize;

    private String     fileId;

    // the storage path
    private String     storageKey;
    // the storage hash code.
    private String     eTag;

    // multipart upload infomation
    private InitResult handle;

    // uploaded parts
    private List<Part> parts;

    // total parts count
    private int        partsCount;

    private String     dataBagId;
    private String     creator;
    private String     updator;

    public int getRevisionNumber() {
        return revisionNumber;
    }

    public void setRevisionNumber(int revisionNumber) {
        this.revisionNumber = revisionNumber;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    public long getFileSize() {
        return fileSize;
    }

    public void setFileSize(long fileSize) {
        this.fileSize = fileSize;
    }

    public String getStorageKey() {
        return storageKey;
    }

    public void setStorageKey(String storageKey) {
        this.storageKey = storageKey;
    }

    /**
     * get the latest Block of this document
     * 
     * @return
     */
    public Part latestPart() {
        Part latest = null;
        if (parts != null) {
            for (Part item : parts) {
                if (latest == null || latest.getIndex() < item.getIndex()) {
                    latest = item;
                }
            }
        }
        return latest;
    }

    public List<Part> getParts() {
        return parts;
    }

    public void setParts(List<Part> parts) {
        this.parts = parts;
    }

    public int getPartsCount() {
        return partsCount;
    }

    public void setPartsCount(int partsCount) {
        this.partsCount = partsCount;
    }

    public String geteTag() {
        return eTag;
    }

    public void seteTag(String eTag) {
        this.eTag = eTag;
    }

    public InitResult getHandle() {
        return handle;
    }

    public void setHandle(InitResult handle) {
        this.handle = handle;
    }

    public String getDataBagId() {
        return dataBagId;
    }

    public void setDataBagId(String dataBagId) {
        this.dataBagId = dataBagId;
    }

    public String getFileId() {
        return fileId;
    }

    public void setFileId(String fileId) {
        this.fileId = fileId;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public String getUpdator() {
        return updator;
    }

    public void setUpdator(String updator) {
        this.updator = updator;
    }

    
    public String getId() {
        return id;
    }

    
    public void setId(String id) {
        this.id = id;
    }
}
